using System.Collections.Generic;
using UnityEngine;

public class btnConnectToSandbox : MonoBehaviour
{
	[SerializeField]
	private List<string> listNameArea = new List<string>();

	public bool startOfflineGame;

	public void OnClick()
	{
		settings.SaveCathedExeptionsToStorager();
		if (!startOfflineGame)
		{
			settings.SetAreaNameForRespawn(SpawnPointChief.listNameArea[Random.Range(0, SpawnPointChief.listNameArea.Count)]);
			if (PhotonNetwork.connected)
			{
				controllerConnectPhoton.thisScript.connectRandomRoom("Level1", TypeGame.TDM);
				if (InGameTutorialStepOnDisable.instance != null && InGameTutorialStepOnDisable.instance.pressButton != null)
				{
					InGameTutorialStepOnDisable.instance.pressButton.Use();
					InGameTutorialStepOnDisable.instance.pressButton = null;
				}
			}
			else if (PlayOfflineWindow.instance != null)
			{
				PlayOfflineWindow.instance.ShowWindow();
			}
		}
		else
		{
			if (InGameTutorialStepOnDisable.instance != null && InGameTutorialStepOnDisable.instance.pressButton != null)
			{
				InGameTutorialStepOnDisable.instance.pressButton.Use();
				InGameTutorialStepOnDisable.instance.pressButton = null;
			}
			controllerMenu.thisScript.playOfflineMode();
		}
	}
}
